Setting up Jenkins in Mac
Steps to follow
There will be a separate section for Download Jenkins 2.206 for:
Under that tap on the macOS or https://jenkins.io/download/weekly/macos
Or Download from the below link which lists all the versions
http://mirrors.jenkins-ci.org/osx/
brew install jenkins
After installation completed, use
brew services start jenkins
Jenkins now will be started in the http://localhost:8080/
Here my Home Directory is shown as /Users/senthilvelp/.jenkins Open the terminal and navigate to your Jenkins Home Directory and type ls in the terminal, it will list a A directory called workspace, so inside this directory all the jobs cloned repo will be there For example, if my job name is xcuitest , then the path where my repos cloned will be /Users/senthilvelp/.jenkins/workspace/xcuitest EXECUTING XCUITESTSteps to Follow
Tap on the Edit scheme option and Tap on the Test option in the below screen Double click on any test plans and then uncheck the automatically add test cases checkbox as shown below
In that execute shell enter #!/bin/bash In the first line of the text box, which will tell Jenkins the following script are executed as bash commands This is known as shebang, it tells the interpreter that the following lines are written for bash For building Xcode for testing, we need CODE_SIGN_IDENTITY and CODE_SIGNING_RELEASE, CODE_SIGN_IDENTITY is used to build apps with different certificates CODE_SIGNING_RELEASE is used for taking debug and release build so give the below command in the Execute shell xcodebuild clean build-for-testing -workspace Freshsales.xcworkspace -scheme SanityTest -sdk iphonesimulator -derivedDataPath /Users/testing/Documents/Firebase -destination 'platform=iOS Simulator,name=iPhone Xs 13.2,OS=13.2.2' CODE_SIGN_IDENTITY="" CODE_SIGNING_RELEASE=NO | xcpretty -s In the above command, we have mentioned the derivedDataPath path where the app will be built and once can see the list of simulators available in the machine by xcrun simctl list , Select a device from the below list and set it in the destination In the above command you can see a third party plugin will be used for formatting the outputs created that is pretty (https://github.com/xcpretty/xcpretty), before using the above command please install xcpretty using gem install xcpretty
xcodebuild -workspace Freshsales.xcworkspace -scheme SanityTest -destination 'platform=iOS Simulator,name=iPhone Xs 13.2,OS=13.2.2' -derivedDataPath /Users/testing/Documents/Firebase test-without-building -testPlan SalesActivitySanityTest | xcpretty -r junit -o /Users/Shared/Jenkins/Home/workspace/SanityTests/junit-report/salesactivity.xml || true In the above command you can see xcpretty have the options to Integrate with junit reports or Html reports, For my convenience, I have given JUnit report and its location where it should be saved, Always make sure the location given should be inside the Jenkins home directory For Xcode version Less than 11 please use the below command xcodebuild test-without-building -xctestrun /Users/user/Documents/FIREBASE/Freshsales-bqgxugtoohekbjdhtlsfimlggamz/Build/Products/SanityTest_iphonesimulator12.4-x86_64.xctestrun -destination 'platform=iOS Simulator,name=iPhone X,OS=12.4' -only-testing:FreshsalesUITests/ContactDetailViewTest/testEditContact_C9275 -only-testing:FreshsalesUITests/ContactDetailViewTest/testNewAccountCreate -only-testing:FreshsalesUITests/ContactDetailViewTest/testDealCreateWithContactAndAccount_C60326757 -only-testing:FreshsalesUITests/ContactDetailViewTest/testDealCreateWithContact_C9253 -only-testing:FreshsalesUITests/DealDetailViewTest/testchangeStageinLanding_C7578093 -only-testing:FreshsalesUITests/DealDetailViewTest/testEditDeal_C8346782 -only-testing:FreshsalesUITests/DealDetailViewTest/testcreateDealwithMultipleContact_C9493_C9472_C9470 In the above command, you can see -xctestrun is provided, which will be generated once App build for testing is completed and it will be in the derived path as mentioned and -only-testing which includes test methods to be ran
Note : The above screenshot uses multi-job plugin , for parallel running to test plans, since freshsales having test plans based on modules like Lead, Contact, Account and Deals, Have created a separate job for each test plans and integrated them to a single Main job For multiple jobs to run, we don't need to build the project each and every time , so just use xcodebuild test command to execute test and all the child job should refer to the same workplace, which can be done as shown in the below screenshot, Just tap the Advanced options in the general tab and it will get expanded and provide the custom location |